Skip to content

Conversation

@ronething
Copy link
Contributor

@ronething ronething commented Jul 4, 2025

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

What this PR does / why we need it:

During the rolling update process, the ingress controller reported an error and is still attempting to synchronize the configuration for the Pods that have been taken offline.

image

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

ronething added 2 commits July 4, 2025 10:57
Signed-off-by: ashing <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the ingress controller continues syncing Pods that are already terminating by skipping them, and it refines the endpoint slice lookup to handle empty slices correctly.

  • Skip endpoints marked as terminating in translateEndpointSlice
  • Rename endpoint to endpoints and change nil check to empty-slice check in getConfigsForGatewayProxy

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/provider/adc/translator/httproute.go Add a check to skip endpoints whose Conditions.Terminating is true
internal/provider/adc/config.go Rename variable and use len(endpoints) == 0 to detect empty slice
Comments suppressed due to low confidence (1)

internal/provider/adc/translator/httproute.go:298

  • Add a unit test to verify that endpoints with Conditions.Terminating == true are correctly skipped by translateEndpointSlice.
					if endpoint.Conditions.Terminating != nil && *endpoint.Conditions.Terminating {

Signed-off-by: ashing <[email protected]>
Comment on lines 298 to 305
if endpoint.Conditions.Ready != nil && !*endpoint.Conditions.Ready {
log.Debugw("skip not ready endpoint", zap.Any("endpoint", endpoint))
continue
}
if endpoint.Conditions.Terminating != nil && *endpoint.Conditions.Terminating {
log.Debugw("skip terminating endpoint", zap.Any("endpoint", endpoint))
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended to put the filter in the controller layer and not manage the status of k8s resources in the translation layer.
https://github.com/apache/apisix-ingress-controller/blob/master/internal/controller/utils.go#L1447

Signed-off-by: ashing <[email protected]>
@ronething ronething changed the title fix: skip terminating endpoint fix: support filter endpoint when translate backend ref. Jul 4, 2025
ronething added 3 commits July 4, 2025 11:46
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Comment on lines +326 to +330
func (t *Translator) TranslateBackendRefWithFilter(tctx *provider.TranslateContext, ref gatewayv1.BackendRef, endpointFilter func(*discoveryv1.Endpoint) bool) (adctypes.UpstreamNodes, error) {
return t.translateBackendRef(tctx, ref, endpointFilter)
}

func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref gatewayv1.BackendRef) (adctypes.UpstreamNodes, error) {
func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref gatewayv1.BackendRef, endpointFilter func(*discoveryv1.Endpoint) bool) (adctypes.UpstreamNodes, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions are exactly the same. Can they be combined into one function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, only the code that retrieves apisix standalone nodes calls the TranslateBackendRefWithFilter method, as it is called from another package, so it has been exported.

We can consider making a unified adjustment in the next PR.

}

func (t *Translator) translateEndpointSlice(portName *string, weight int, endpointSlices []discoveryv1.EndpointSlice) adctypes.UpstreamNodes {
func (t *Translator) translateEndpointSlice(portName *string, weight int, endpointSlices []discoveryv1.EndpointSlice, endpointFilter func(*discoveryv1.Endpoint) bool) adctypes.UpstreamNodes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems to cover the functionality of translateEndpointSliceForIngress. It seems that translateEndpointSliceForIngress can be removed or called translateEndpointSlice in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a need for more clarification. It may not be appropriate to make adjustments in this PR, as it involves more code changes.

@ronething ronething merged commit ebdafea into apache:master Jul 4, 2025
27 of 28 checks passed
@ronething ronething deleted the fix/pod_sync branch July 4, 2025 06:10
AlinsRan pushed a commit that referenced this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants